<?php

namespace App\Http\Service;

use App\Http\Util\Result;
use App\Model\FunctionThree;
use App\Model\Scenery;
use Illuminate\Support\Facades\DB;

trait ServiceFunctionThree{

    /**
     * czs
     * @return mixed
     * 景区规则分类列表
     */
    public static function getList($id,$limit){
        $list = FunctionThree::where("detail_id",$id)->orderBy('id','desc')->paginate($limit);
        return Result::success()->setData($list);
    }

    /**
     * @return mixed
     * 未勾选的景点
     * czs
     */
    public static function leaveCheck(){
        $res = Scenery::where('detail_id',0)->orwhere('detail_id',NULL)->get();
        return Result::success()->setData($res);

    }

    /**
     * @return mixed
     * 已勾选的景点
     * czs
     */
    public static function editCheck($id){
        $res = Scenery::where('detail_id',$id)->get();
        return Result::success()->setData($res);

    }

    /**
     * 更新三级规则
     * czs
     */
    public static function updateData($input,$id) {
        if ($input['start_time']>=$input['end_time']) {
            return Result::failure()->setMsg("开始时间勿大于结束时间！");
        }
        $res = FunctionThree::where('id',$id)->update($input);
        return Result::success()->setData($res);
    }

    /**
     *获取单个id记录
     * czs
     */
    public static function getOne($id) {
        $res = FunctionThree::where("id", $id)->first();
        return Result::success()->setData($res);
    }

    /**
     * czs
     *删除记录
     */
    public static function deleteLine($id) {
        $res = FunctionThree::where("id", $id)->delete();
        return Result::success()->setData($res);
    }
}


